<%--  <%@ include  file="/other/Header.jsp" %> 
 --%> <%@page import="beans.report.CallStatus"%>
<%@page import="org.apache.commons.beanutils.RowSetDynaClass"%>
<%@page import="java.sql.Types"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.CallableStatement"%>
<%@page import="java.sql.Connection"%>
<jsp:directive.page import="Connectivity.ConnectionManager"/>
<%@page import="beans.Contact"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%

 String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String back = request.getParameter("Activity")!=null?request.getParameter("Activity"):"2"; 
 
String status = request.getParameter("status")!=null?request.getParameter("status"):"";
String calltype = request.getParameter("calltype")!=null?request.getParameter("calltype"):"";
String fdate = request.getParameter("fdate")!=null?request.getParameter("fdate"):"";
String tdate = request.getParameter("tdate")!=null?request.getParameter("tdate"):"";



System.out.println("calltype"+calltype);
String Headinglabel="CALL REPORT";
if(calltype.equalsIgnoreCase("ASSIGNED"))
{Headinglabel="CALL ASSIGNED";}
if(calltype.equalsIgnoreCase("CLOSED"))
{Headinglabel="CALL CLOSED";}
if(calltype.equalsIgnoreCase("MTAKEN"))
{Headinglabel="MATERIAL TAKEN";}
if(calltype.equalsIgnoreCase("MGIVEN"))
{Headinglabel="MATERIAL GIVEN";}
if(calltype.equalsIgnoreCase("PFP"))
{Headinglabel="PENDING FOR PARTS";}
if(calltype.equalsIgnoreCase("0$all"))
{calltype="ALL";}

%>

<!DOCTYPE html >
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CALL STATUS</title>
   <link rel="stylesheet" href="css/displaytag.css" type="text/css">
        <link rel="stylesheet" href="css/screen.css" type="text/css">
       <link rel="stylesheet" href="css/site.css" type="text/css">
 </head>
<body>
<%
 
 CallableStatement cstmt = null;
	ResultSet calldisplayrs = null;
     boolean flag=false;
     int count=1;
     String compalint_id="-",customer_name="-",area="-",cust_type="-",callentry_id="",assigndate="",employee_name="";
    try
    {
    	Connection conn = ConnectionManager.getConnection();
    	 if(calltype.equalsIgnoreCase("PFP")){calltype="PFPE";}
    	 
			cstmt = conn.prepareCall("{?=call fun_retrieve_call_report(?,?,?,?)}");
			cstmt.registerOutParameter(1, Types.OTHER);
			cstmt.setString(2,calltype);
    		cstmt.setString(3,fdate);
			cstmt.setString(4,tdate);
			cstmt.setObject(5,calldisplayrs);
			
			conn.setAutoCommit(false);
			cstmt.execute();
			
	calldisplayrs =(ResultSet) cstmt.getObject(1);	
    List<CallStatus> statusLst = new ArrayList<CallStatus>();

    while(calldisplayrs.next())
     {
     CallStatus cs = new CallStatus();
     cs.setSrno(count++);
     cs.setAssignDate(calldisplayrs.getString(2));
     cs.setCompalintId(calldisplayrs.getString(3));
     cs.setCallentryId(calldisplayrs.getString(1));
     cs.setCustomerName(calldisplayrs.getString(4));
     cs.setArea(calldisplayrs.getString(5));
     cs.setCustType(calldisplayrs.getString(6));
     cs.setCallDetails(calldisplayrs.getString(7));
     cs.setItem(calldisplayrs.getString(8));
     cs.setEmployeeName(calldisplayrs.getString(9));
     cs.setCallStatus(calldisplayrs.getString(10));
   	 if(calltype.equals("PFPE") || calltype.equals("ASSIGNED"))
  	{cs.setCallDuration(calldisplayrs.getString(11));}
  	if(calltype.equals("CLOSED"))
  	{cs.setActionTaken(calldisplayrs.getString(11));}
  	 //out.println(cs.toString());
  	 statusLst.add(cs);
     }
    //out.println(statusLst.toString());
    session.setAttribute("statusLst", statusLst);
        %>
 	
    <table align=center border=1>
    <tr><td colspan="1" width="90%"><h2>Call Status Report</h2></td>
        <td colspan="1" align=right><img src="<%=basePath%>images\Company.jpg" height=100 width=100></td></tr>
        <tr><td colspan="2">
		<display:table name="sessionScope.statusLst" pagesize="15" export="true" sort="list" uid="one">
                <display:column property="srno" title="Sr. No." sortable="true" headerClass="sortable" />
                <display:column property="assignDate" title="DATE" sortable="true" headerClass="sortable" />
                <display:column property="compalintId" title="COMPLAINT ID" sortable="true" headerClass="sortable" />
                <display:column property="customerName" title="CUSTOMER NAME" sortable="true" headerClass="sortable" />
                <display:column property="area" title="BRANCH" sortable="true" headerClass="sortable" />
                <display:column property="callDetails" title="NATURE OF FAULT" sortable="true" headerClass="sortable" />
                <display:column property="item" title="ITEM" sortable="true" headerClass="sortable" />
                <display:column property="employeeName" title="EMPLOYEE" sortable="true" headerClass="sortable" />
                <% if(calltype.equals("PFPE") || calltype.equals("ASSIGNED")) { %>
                <display:column property="callDuration" title="PENDING FROM" sortable="true" headerClass="sortable" />
                <%} if(calltype.equals("CLOSED")){ %>
                <display:column property="actionTaken" title="ACTION TAKEN" sortable="true" headerClass="sortable" />
                <%}  if(calltype.equals("ALL")) {%>
                <display:column property="callStatus" title="CALL STATUS" sortable="true" headerClass="sortable" />
				<%} %> 
		<display:setProperty name="export.excel.filename"
			value="Call Status.xls" />
		<display:setProperty name="export.pdf.filename"
			value="ActorDetails.pdf" />
		 <display:setProperty name=""
			value="ActorDetails.csv" /> 
		<display:setProperty name="export.pdf" value="true" />
            </display:table>
    <%}
    catch(Exception e)
    {e.printStackTrace();}
     %> 
     <div class="exportlinks">
     <a href ="javascript:history.back()" >Back</a> 
        </div></td></tr>
        
        </table>
        
        
</body>
</html>